/*
 * FileName: SenderController.java
 * Author:   zzw
 * Date:     2018年05月23日
 * Description:
 */
package com.chezhibao.trace.controller;

import com.chezhibao.trace.vo.Message;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

/**
 * 〈〉<br>
 * 〈〉
 *
 * @author zzw
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本]（可选）
 */
@RestController
public class SenderController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @Autowired
    private ObjectMapper objectMapper;

    @GetMapping("/send")
    public String sender() throws IOException, ExecutionException, InterruptedException {
        Message message = new Message();
        ListenableFuture<SendResult<String, String>> re = kafkaTemplate.send("trace", 0, "123123123|121312313|0|test|1.0.0.16|12312|eqwe|200|@123123123");
        return re.get().toString();
    }
}
